import java.util.LinkedList;
import java.util.Scanner;
public class abc {
    public static void main(String[] args) {
        LinkedList<Student> students = new LinkedList<Student>();
        students.add(new Student("2020212201","小王",22,"计算机科学与技术1班"));
        students.add(new Student("2020213201","小刘",20,"软件工程1班1班"));
        students.add(new Student("2020212511","小李",21,"土木工程1班班"));
        students.add(new Student("2020217251","小赵",21,"电子商务1班"));
        System.out.println("学号"+"\t\t\t"+"姓名"+"\t"+"年龄"+"\t"+"班级");
        for (Student student : students) {
            System.out.println(student.toString());

        }
        Scanner scanner = new Scanner(System.in);
        Student ss;
        while (true) {
            System.out.println("请输入学号（输入exit退出）：");
            String input = scanner.nextLine();
            if (input.equals("exit")) {
                System.out.println("退出学生信息搜索系统");
                break;
            }
            if (input.equals("input")) {
                System.out.println("退出学生信息搜索系统");
                break;
            }
            Student result = searchstudent(students,input);
            if (result != null) {
                System.out.println("搜索结果：" + result);
            } else {
                System.out.println("未找到对应学号的学生信息");
            }
        }
        scanner.close();
    }
    static Student searchstudent(LinkedList<Student> studentList,String studentld) {
        for (Student student : studentList) {
            if (student.getStudentld().equals(studentld)) {
                return student;
            }
        }
        return null;
    }
}

class Student {
    private String studentld;
    private String name;
    private int age;
    private String className;

    public Student(String studentld,String name,int age,String className) {
        this.studentld=studentld;
        this.name=name;
        this.age=age;
        this.className=className;
    }

    public String getStudentld() {
        return studentld;
    }
    public String getName() {
        return name;
    }
    public int getAge() {
        return age;
    }
    public String getclassName() {
        return className;
    }
    public String toString() {
        return
                studentld + "\t" + name+ "\t" + age +"\t" + className;
    }
}


